﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace FinalSilverlightProject.Web.Models
{

    public class AdministratorAndCustomerRoleAttribute : AuthorizationAttribute
    {
        protected override AuthorizationResult IsAuthorized(System.Security.Principal.IPrincipal principal, AuthorizationContext authorizationContext)
        {
            if (principal.IsInRole("Administrators") || principal.IsInRole("Customers"))
                return AuthorizationResult.Allowed;
            else
                return new AuthorizationResult(
                    "You do not have sufficient rights to perform this operation.");
        }
    }
}